<template>
  <div class="header">
    <div class="content-wapper">
      <div class="avatar">
        <img class="avatar-img" :src="seller.avatar" :alt="seller.name"/>
      </div>
      <div class="content">
        <div class="title">
          <span class="brand"></span>
          <span class="name" v-text="seller.name"></span>
        </div>
        <div class="description">
          {{seller.description}} / {{seller.deliveryTime}}分钟送达
        </div>
        <div class="supports" v-if="seller.supports">
          <span class="icon" :class="classMap[seller.supports[0].type]"></span>
          <span class="text">{{seller.supports[0].description}}</span>
        </div>
      </div>
      <div class="supports-count" v-if="seller.supports" @click="detailShow">
        <span class="count">{{seller.supports.length}}个</span>
        <i class="icon-keyboard_arrow_right"></i>
      </div>
    </div>
    <div class="bulletin-wapper" @click="detailShow">
      <span class="bulletin"></span><span class="bulletin-text">{{seller.bulletin}}</span>
      <i class="icon-keyboard_arrow_right"></i>
    </div>
    <div class="background">
      <img :src="seller.avatar" width="100%" height="100%">
    </div>
    <fade-animate>
      <div class="detail" v-show="showDetail" @click="detailHide" ref="detail">
        <div>
          <div class="detail-wapper clearfix">
            <div class="detail-main">
              <h1 class="detail-name">{{seller.name}}</h1>
              <div class="star-wapper">
                <star :size="48" :score="seller.score"></star>
              </div>
              <div class="title">
                <div class="line"></div>
                <div class="text">优惠信息</div>
                <div class="line"></div>
              </div>
              <ul class="supports" v-if="seller.supports">
                <li class="support-item" v-for="item of seller.supports" :key="item.type">
                  <span class="icon" :class="classMap[item.type]"></span>
                  <span class="text">{{item.description}}</span>
                </li>
              </ul>
              <div class="title">
                <div class="line"></div>
                <div class="text">商家公告</div>
                <div class="line"></div>
              </div>
              <div class="bulletin">
                <p class="content">
                  {{seller.bulletin}}
                  {{seller.bulletin}}
                </p>
              </div>
            </div>
          </div>
          <div class="detail-close" @click="detailHide">
            <i class="icon-close"></i>
          </div>
        </div>
      </div>
    </fade-animate>
  </div>
</template>
<script>
import FadeAnimate from 'common/fade/FadeAnimate'
import Star from 'common/star/Star'
export default {
  name: 'SellHeader',
  props: {
    seller: Object
  },
  components: {
    FadeAnimate,
    Star
  },
  data () {
    return {
      showDetail: false
    }
  },
  methods: {
    detailShow () {
      this.showDetail = true
    },
    detailHide () {
      this.showDetail = false
    }
  },
  created () {
    this.classMap = ['decrease', 'discount', 'special', 'invoice', 'guarantee']
  }
}
</script>
<style lang="stylus" scoped>
  @import "~styles/mixin.styl"
  .header
    color #fff
    position relative
    background rgba(7, 17, 27, 0.5)
    overflow hidden
    .content-wapper
      padding .48rem .24rem .36rem .48rem
      font-size 0
      position relative
      .avatar
        display inline-block
        .avatar-img
          width 1.28rem
          height 1.28rem
          vertical-align inherit
          border-radius .1rem
      .content
        display inline-block
        margin-left .32rem
        vertical-align top
        .title
          margin .04rem 0 .16rem 0
          .brand
            vertical-align top
            display inline-block
            width .6rem
            height .36rem
            bg-image('img/brand')
            background-size .6rem .36rem
            background-repeat no-repeat
          .name
            margin-left .12rem
            font-size .32rem
            line-height .36rem
            font-weight bold
        .description
          font-size .24rem
          line-height .24rem
          font-weight 200
          margin-bottom .2rem
        .supports
          padding-bottom .1rem
          .icon
            vertical-align top
            display inline-block
            width .24rem
            height .24rem
            margin-right .08rem
            background-size .24rem .24rem
            background-repeat no-repeat
            &.decrease
              bg-image('img/decrease_1')
            &.discount
              bg-image('img/discount_1')
            &.guarantee
              bg-image('img/guarantee_1')
            &.invoice
              bg-image('img/invoice_1')
            &.special
              bg-image('img/special_1')
          .text
            font-size .2rem
            line-height .24rem
        .bulletin
          width 80%
          margin 0 auto

      .supports-count
        position absolute
        right .24rem
        bottom .36rem
        padding 0 .16rem 0 .2rem
        height .48rem
        line-height .48rem
        border-radius .28rem
        background-color rgba(0, 0, 0, .2)
        text-align center
        .count
          font-size .2rem
        .icon-keyboard_arrow_right
          padding .14rem 0
          margin-left .04rem
          line-height .48rem
          font-size .2rem
    .bulletin-wapper
      height .56rem
      line-height .56rem
      padding 0 .48rem 0 .24rem
      position relative
      background rgba(7, 17, 27, 0.2)
      ellipsis()
      .bulletin
        display inline-block
        width .44rem
        height .24rem
        bg-image('img/bulletin')
        background-size .44rem .24rem
        background-repeat no-repeat
        vertical-align top
        margin-top .15rem
      .bulletin-text
        font-size .2rem
        font-weight 200
        margin 0 .08rem
        vertical-align top
      .icon-keyboard_arrow_right
        position absolute
        right .24rem
        bottom -0.02rem
        font-size .2rem
    .background
      position absolute
      top 0
      left 0
      width 100%
      height 100%
      z-index -1
      filter blur(10px)
    .detail
      position fixed
      top 0
      left 0
      width 100%
      height 100%
      background rgba(7, 17, 27, 0.8)
      z-index 100
      backdrop-filter blur(10px)
      overflow auto
      .detail-wapper
        min-height 100%
        width 100%
        .detail-main
          margin-top 1.28rem
          padding-bottom 1.28rem
          .detail-name
            font-size .32rem
            font-weight 700
            line-height .32rem
            text-align center
          .star-wapper
            margin-top .64rem
            text-align center
            padding .04rem 0
          .title
            display flex
            width 80%
            margin .56rem auto .48rem auto
            .line
              flex 1
              position relative
              top -.12rem
              border-bottom .02rem solid rgba(255, 255, 255, 0.2)
            .text
              padding 0 .24rem
              font-size .28rem
              font-weight 700
              line-height .32rem
          .supports
            width 80%
            margin 0 auto
            .support-item
              padding 0 .24rem
              margin-bottom .24rem
              font-size 0
              &:last-child
                margin-bottom 0
              .icon
                display inline-block
                width .32rem
                height .32rem
                vertical-align top
                margin-right .12rem
                background-size .32rem .32rem
                background-repeat no-repeat
                &.decrease
                  bg-image('img/decrease_2')
                &.discount
                  bg-image('img/discount_2')
                &.guarantee
                  bg-image('img/guarantee_2')
                &.invoice
                  bg-image('img/invoice_2')
                &.special
                  bg-image('img/special_2')
              .text
                font-size .24rem
                font-weight 200
                line-height .32rem
          .bulletin
            width 80%
            margin 0 auto
            .content
              font-size .24rem
              font-weight 200
              line-height .48rem
              padding 0 .24rem
      .detail-close
        position relative
        width .64rem
        height .64rem
        margin -1.28rem auto 0 auto
        font-size .64rem
        opacity .5
</style>
